/**
 * 用户相关请求模块
 */
import type { Patient, PatientList, User, UserInfo } from '@/types/user'
import { request } from '@/utils/request'
import type { CodeType } from '@/types/user'

// 密码登录
export const loginByPassword = (mobile: string, password: string) =>
  request.post<any, User>('/login/password', { mobile, password })

// 短信登录
export const loginByMobile = (mobile: string, code: string) =>
  request.post<any, User>('/login', { mobile, code })

// 发送验证码
export const sendMobileCode = async (mobile: string, type: CodeType) =>
  request.get<any, { code: string }>('/code', { params: { mobile, type } })

// 获取个人信息
export const getUserInfo = () => request.get<any, UserInfo>('patient/myUser')

// 获取患者列表
export const getPatientList = () => request.get<any, PatientList>('patient/mylist')

// 新增患者信息
export const addPatient = (patient: Patient) => request.post('patient/add', patient)

// 编辑患者信息
export const editPatient = (patient: Patient) =>
  request.put<any, Patient>('patient/update', patient)

// 删除患者信息
export const delPatient = (id: string) => request.delete(`patient/del/${id}`)

// 查询患者详情
export const getPatientDetail = (id: string) => request.get<any, Patient>(`/patient/info/${id}`)
